package com.wc.alorithm_luogu.P1328;

import java.util.Scanner;

/**
 * @author congege
 * @create 2023:04:26 5:11
 * @describe https://www.luogu.com.cn/problem/P1328
 * 生活大爆炸版石头剪刀布
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 出拳次数
        int n = sc.nextInt();
        // A的周期
        int n1 = sc.nextInt();
        // B的周期
        int n2 = sc.nextInt();

        int[] A = new int[n1];
        int[] B = new int[n2];
        for (int i = 0; i < n1; i++) {
            A[i] = sc.nextInt();
        }
        for (int i = 0; i < n2; i++) {
            B[i] = sc.nextInt();
        }
        int indexA = 0;
        int indexB = 0;
        int scoreA = 0;
        int scoreB = 0;
        Main main = new Main();
        int win;
        while (n-- > 0) {
            win = main.guessFis(A[indexA], B[indexB]);
            if (win < 0) {
                scoreA++;
            } else if (win > 0) {
                scoreB++;
            }
            indexA = (indexA + 1) % n1;
            indexB = (indexB + 1) % n2;
        }
        System.out.println(scoreA + " " + scoreB);
    }

    /**
     * 猜拳
     * 0 剪刀     赢 布   蜥蜴人
     * 1 石头     赢 剪刀 蜥蜴人
     * 2 布      赢 石头 斯波克
     * 3 蜥蜴人   赢 布   斯波克
     * 4 斯波克   赢  剪刀 石头
     *
     * @param left  左面出的
     * @param right 右面出的
     * @return -1 代表左面赢
     * 0 代表平局
     * 1 代表右面赢
     */
    public int guessFis(int left, int right) {
        if (left == right) {
            return 0;
        }
        if (left == 0) {
            if (right == 2 || right == 3) {
                return -1;
            }
            return 1;
        }
        if (left == 1) {
            if (right == 0 || right == 3) {
                return -1;
            }
            return 1;
        }
        if (left == 2) {
            if (right == 1 || right == 4) {
                return -1;
            }
            return 1;
        }

        if (left == 3) {
            if (right == 2 || right == 4) {
                return -1;
            }
            return 1;
        }
        if (right == 0 || right == 1) {
            return -1;
        }
        return 1;
    }
}
